<template>
	<a-divider>{{ $t('login.signInOther') }}</a-divider>
	<div class="login-oauth layout-center">
		<a-space align="start">
			<a-button type="primary" shape="circle">
				<wechat-filled @click="thirdLogin()" />
			</a-button>
		</a-space>
	</div>
	<a-modal v-model:visible="visible" title="企业微信登录" @ok="handleOk">
		<div id="wx_qrcod"></div>
	</a-modal>
</template>

<script setup name="threeLogin">
	import thirdApi from '@/api/auth/thirdApi'
	import * as ww from '@wecom/jssdk'

	const visible = ref(false)

	const getLoginRenderUrl = (platform) => {
		const param = {
			platform: platform
		}
		thirdApi.thirdRender(param).then((data) => {
			window.location.href = data.authorizeUrl
		})
	}

	const handleOk = () => {
		console.log(1212)
	}
	const option = ref({
		el: '#wx_qrcod',
		params: {
			login_type: 'CorpApp', //企业: CorpID，第三方: SuiteID
			appid: 'ww905ad891d7b2fec1',
			agentid: '1000002',
			redirect_uri: 'http://bb9332vo9815.vicp.fun/',
			state: 'loginState',
			redirect_type: 'callback'
		},
		onCheckWeComLogin({ isWeComLogin }) {
			console.log(isWeComLogin)
		},
		onLoginSuccess({ code }) {
			// 此处调用服务端接口，处理code
		},
		onLoginFail({ err }) {
			console.log(err)
		}
	})

	const thirdLogin = () => {
		ww.createWWLoginPanel(option.value)
		visible.value = true
	}
</script>
